package WaiBao;

import java.util.Arrays;

public class FengJingMin {
    public static void main(String[] args) {
        String[] name = {"李雪(班长)", "陈梅(副班长)", "小李(学习委员)", "石榴(团支书)", "马磊", "叶少良", "魏倩", "钟意", "贾德佳", "谢红", "胡慧珍", "文君",
                "蕾蕾", "何国秀", "田文澜", "王泽峰", "将华宇", "刘梅", "孙亚文", "李晓梅", "杜小兰", "李小春", "李静瑶", "胡橘芳", "王波", "刘佳", "沈霞", "彭海燕",
                "沈玲玲", "冯静敏(学生)"};//考生本人:冯静敏(学生)
        int[] age = {21, 19, 17, 18,20, 19, 20, 20, 19, 19,21, 20, 18, 20, 20, 19, 20, 18, 18, 18, 20, 19, 20, 20, 20, 18, 19, 19, 18, 21};//考生年龄：21岁

        double[] yanjing1 = {86, 75, 85, 84, 77, 69, 90, 84, 81, 81, 91, 87, 75, 79, 65, 68, 99, 99, 96, 88, 92, 91, 95, 75, 75, 74, 94, 74, 85, 97};
        double[] yanjing2 = {84, 67, 75, 66, 78, 67, 68, 68, 80, 70, 80, 77, 66, 85, 65, 65, 76, 99, 66, 98, 72, 71, 90, 86, 75, 85, 71, 64, 81, 96};
        double[] yanjing3 = {74, 77, 80, 75, 75, 64, 70, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 77, 89, 93};


        double aoli1 ;//代表每个学生的总分
//        double aoli2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            aoli1 =yanjing1[i] + yanjing2[i] + yanjing3[i];
//            aoli2 = (aoli1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + aoli1);
//            System.out.println(name[i] + "的平均分为:" + aoli2);
//        }


        double baicai1 = 0,baicai2 = 0;
        double[] luobo = new double[30];
//        for (int i = 0; i < 30; i++) {
//            baicai1 = yanjing1[i] +yanjing2[i] + yanjing3[i];
//            baicai2 = (baicai1 * 1.0) / 3;
//            luobo[i] = baicai2;
//        }
//
//        for (int i = 0; i <  luobo.length - 1; i++) {
//            for (int j = 0; j <luobo.length - i - 1; j++) {
//                if (luobo[j] <luobo[j + 1]) {
//                    double tep =luobo[j];
//                    luobo[j] =luobo[j + 1];
//                    luobo[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(luobo[i]);
//        }


        double wangfei1 = 0,wangfei2 = 0,wangfei3 = 0;//计算每门课的平均分
        double lixing1 = 0,lixing2 = 0,lixing3 = 0;//计算每门课标准差
        double wangyue1 = 0,wangyue2 = 0,wangyue3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < yanjing1.length; i++) {
            he +=yanjing1[i];
        }
        wangfei1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +wangfei1);
        double Sum = 0;
        for (int i = 0; i < yanjing2.length; i++) {
            Sum +=yanjing2[i];
        }
        wangfei2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + wangfei2);
        double sum = 0;
        for (int i = 0; i < yanjing3.length; i++) {
            sum += yanjing3[i];
        }
        wangfei3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +wangfei3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < yanjing1.length; i++) {
            c1 += (yanjing1[i] - wangfei1) * (yanjing1[i] -wangfei1);
        }
        lixing1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + lixing1);
        for (int i = 0; i <yanjing2.length; i++) {
            c2 += (yanjing2[i] - wangfei2) * (yanjing2[i] -wangfei2);
        }
        lixing2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +lixing2);

        for (int i = 0; i <yanjing3.length; i++) {
            c3 += (yanjing3[i] -wangfei3) * (yanjing3[i] - wangfei3);
        }
        lixing3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +lixing3);
////
//////
        Arrays.sort(yanjing1);
        Arrays.sort(yanjing2);
        Arrays.sort(yanjing3);
        wangyue1 = (yanjing1[15] +yanjing2[14]) * 1.0 / 2;
        wangyue2 = (yanjing2[15] +yanjing2[14]) * 1.0 / 2;
        wangyue3 = (yanjing3[15] +yanjing3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + wangyue1);
        System.out.println("农业设施设计与制造的中位数为:" + wangyue2);
        System.out.println("园艺植物设施栽培学的中位数为:" + wangyue3);



    }
}

